const PermissionServices = require("../services/PermissionServices")
const { errorResponese, successResponese } = require("../utils/validate")
const PermissionController = {
    find: async (ids) => {
        let permissionResult = []
        for (let i = 0; i < ids.length; i++) {
            const id = ids[i];
            let result = await PermissionServices.find(id)
            if (result)  {
                permissionResult = [...permissionResult,...result]
                continue
            }
            errorResponese({
                res,
                msg: "查询失败"
            })
        }
        return permissionResult
    },
    append: (res,body) => {
        let result = PermissionServices.append(body)

        if (result) return successResponese({
            res,
            msg: "创建成功"
        })

        errorResponese({
            res,
            msg: "创建失败"
        })
    },
    update: () => {

    },
    remove: () => {

    }
}

module.exports =  PermissionController